package halberd.utils;

import java.awt.image.BufferedImage;

import halberd.DataType;
import halberd.data.ImgData;

public class BufferedImageToImgData {
	public static void fillRGB(BufferedImage bi,ImgData id){
		int width = bi.getWidth();  
        int height = bi.getHeight();  
        int minx = bi.getMinX();  
        int miny = bi.getMinY();  
        for (int i = minx,x=0; i < width; i++,x++) {  
            for (int j = miny,y=0; j < height; j++,y++) {  
                int pixel = bi.getRGB(i, j); 
                int r = (pixel & 0xff0000) >> 16;  
                int g = (pixel & 0xff00) >> 8;  
                int b = (pixel & 0xff); 
                id.put(x, y, r, g, b); 
            }  
        } 
        id.setDataType(DataType.RGB);
	}
}
